package com.focusai.efairy.ui.activity.dev;

import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.view.KeyEvent;

import com.focusai.efairy.R;
import com.focusai.efairy.model.project.ProjectItem;
import com.focusai.efairy.ui.base.SwipeBackBaseActivity;
import com.focusai.efairy.ui.fragment.DevFragment;

/**
 * Created by luo_guangwen on 2017/8/14.
 */

public class DeviceListActivity extends SwipeBackBaseActivity {
    public static final String PROJECT_ITEM = "project_item";
    private DevFragment fragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.act_dev_list);
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        Bundle bundle = new Bundle();
        bundle.putBoolean(DevFragment.KEY_KEYWORD, true);
        if (getIntent() != null) {
            ProjectItem projectItem = (ProjectItem) getIntent().getSerializableExtra(PROJECT_ITEM);
            bundle.putSerializable(DevFragment.KEY_PROJECT_ITEM, projectItem);
        }
        fragment = new DevFragment();
        fragment.setArguments(bundle);
        transaction.add(R.id.flayout_contain, fragment);
        transaction.commit();
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (fragment.onKeyDown(keyCode,event)){
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

    @Override
    protected boolean hasActionBar() {
        return false;
    }
}
